Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

c12

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c12

Smart Config Loader

  • 1.11.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
883K
decreased by-16.44%
Maintainers
1
Weekly downloads
 
Created

What is c12?

The c12 npm package is a configuration loader and manager that helps in loading, merging, and managing configurations from various sources such as files, environment variables, and more. It is designed to be flexible and easy to use, making it suitable for a wide range of applications.

What are c12's main functionalities?

Loading Configuration from Files

This feature allows you to load configuration from files. The `loadConfig` function reads configuration files based on the provided options such as the name of the application and the current working directory.

const { loadConfig } = require('c12');

async function loadConfigExample() {
  const config = await loadConfig({
    name: 'myapp',
    cwd: process.cwd(),
    rcFile: true
  });
  console.log(config);
}

loadConfigExample();

Merging Configurations

This feature allows you to merge configurations from different sources. The `loadConfig` function can take default configurations and override configurations, merging them into a single configuration object.

const { loadConfig } = require('c12');

async function mergeConfigExample() {
  const config = await loadConfig({
    name: 'myapp',
    defaults: { key1: 'default1' },
    overrides: { key2: 'override2' }
  });
  console.log(config);
}

mergeConfigExample();

Loading Configuration from Environment Variables

This feature allows you to load configuration from environment variables. The `loadConfig` function can be configured to read environment variables with a specific prefix and include them in the configuration object.

const { loadConfig } = require('c12');

async function envConfigExample() {
  process.env.MYAPP_KEY = 'valueFromEnv';
  const config = await loadConfig({
    name: 'myapp',
    envPrefix: 'MYAPP_'
  });
  console.log(config);
}

envConfigExample();

Other packages similar to c12

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc